{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# 数据分析与可视化实战案例：学习时间与成绩的关系（线性回归）\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "观察数据、导入数据、划分特征和标签、划分训练集和测试集、构建模型，模型可视化\n",
    "\n",
    "张子豪 同济大学研究生 2019-5-30\n",
    "\n",
    "Bilibili视频教程：[同济子豪兄](https://space.bilibili.com/1900783/#/)<br>\n",
    "\n",
    "知乎专栏：[人工智能小技巧](https://zhuanlan.zhihu.com/c_1032626015746502656)<br>\n",
    "\n",
    "简书专栏：[人工智能小技巧](https://www.jianshu.com/u/38cccf09b515)<br>\n",
    "\n",
    "子豪兄的粉丝答疑交流QQ群：953712961"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## 第0步 把玩数据\n",
    "用excel打开数据集，绘制散点图，添加趋势线，可以看到，学习时间与成绩存在明显的线性相关关系\n",
    "用excel里面的=intercept、=slope函数可以拟合出斜率和截距。"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## 第1步：导入数据分析库pandas，数据可视化库matplotlib\n",
    " `%matplotlib inline`是Ipython的魔法函数，其作用是使matplotlib绘制的图像嵌入在juptyer notebook的单元格里"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 27,
   "metadata": {},
   "outputs": [],
   "source": [
    "import pandas as pd\n",
    "import matplotlib.pyplot as plt\n",
    "%matplotlib inline"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## 第2步：导入数据集，查看数据集"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {
    "scrolled": false
   },
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>Hours</th>\n",
       "      <th>Scores</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>2.5</td>\n",
       "      <td>21</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>5.1</td>\n",
       "      <td>47</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>3.2</td>\n",
       "      <td>27</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>8.5</td>\n",
       "      <td>75</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>3.5</td>\n",
       "      <td>30</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>5</th>\n",
       "      <td>1.5</td>\n",
       "      <td>20</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>6</th>\n",
       "      <td>9.2</td>\n",
       "      <td>88</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>7</th>\n",
       "      <td>5.5</td>\n",
       "      <td>60</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>8</th>\n",
       "      <td>8.3</td>\n",
       "      <td>81</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>9</th>\n",
       "      <td>2.7</td>\n",
       "      <td>25</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "   Hours  Scores\n",
       "0    2.5      21\n",
       "1    5.1      47\n",
       "2    3.2      27\n",
       "3    8.5      75\n",
       "4    3.5      30\n",
       "5    1.5      20\n",
       "6    9.2      88\n",
       "7    5.5      60\n",
       "8    8.3      81\n",
       "9    2.7      25"
      ]
     },
     "execution_count": 3,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "dataset = pd.read_csv('./studentscores.csv')\n",
    "dataset.head(10)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "(25, 2)"
      ]
     },
     "execution_count": 11,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "dataset.shape"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 12,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "Index(['Hours', 'Scores'], dtype='object')"
      ]
     },
     "execution_count": 12,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "dataset.columns"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "metadata": {
    "scrolled": true
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "<class 'pandas.core.frame.DataFrame'>\n",
      "RangeIndex: 25 entries, 0 to 24\n",
      "Data columns (total 2 columns):\n",
      "Hours     25 non-null float64\n",
      "Scores    25 non-null int64\n",
      "dtypes: float64(1), int64(1)\n",
      "memory usage: 480.0 bytes\n"
     ]
    }
   ],
   "source": [
    "dataset.info()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "metadata": {
    "scrolled": false
   },
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>Hours</th>\n",
       "      <th>Scores</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>count</th>\n",
       "      <td>25.000000</td>\n",
       "      <td>25.000000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>mean</th>\n",
       "      <td>5.012000</td>\n",
       "      <td>51.480000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>std</th>\n",
       "      <td>2.525094</td>\n",
       "      <td>25.286887</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>min</th>\n",
       "      <td>1.100000</td>\n",
       "      <td>17.000000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>25%</th>\n",
       "      <td>2.700000</td>\n",
       "      <td>30.000000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>50%</th>\n",
       "      <td>4.800000</td>\n",
       "      <td>47.000000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>75%</th>\n",
       "      <td>7.400000</td>\n",
       "      <td>75.000000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>max</th>\n",
       "      <td>9.200000</td>\n",
       "      <td>95.000000</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "           Hours     Scores\n",
       "count  25.000000  25.000000\n",
       "mean    5.012000  51.480000\n",
       "std     2.525094  25.286887\n",
       "min     1.100000  17.000000\n",
       "25%     2.700000  30.000000\n",
       "50%     4.800000  47.000000\n",
       "75%     7.400000  75.000000\n",
       "max     9.200000  95.000000"
      ]
     },
     "execution_count": 10,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "dataset.describe()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## 第3步：提取特征\n",
    "### 提取特征：学习时间 提取标签：学习成绩"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 13,
   "metadata": {},
   "outputs": [],
   "source": [
    "feature_columns = ['Hours']\n",
    "label_column = ['Scores']"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 14,
   "metadata": {},
   "outputs": [],
   "source": [
    "features = dataset[feature_columns]\n",
    "label = dataset[label_column]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 17,
   "metadata": {
    "scrolled": true
   },
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>Hours</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>2.5</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>5.1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>3.2</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>8.5</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>3.5</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "   Hours\n",
       "0    2.5\n",
       "1    5.1\n",
       "2    3.2\n",
       "3    8.5\n",
       "4    3.5"
      ]
     },
     "execution_count": 17,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "features.head()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 28,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "pandas.core.frame.DataFrame"
      ]
     },
     "execution_count": 28,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "type(features)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 18,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>Scores</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>21</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>47</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>27</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>75</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>30</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "   Scores\n",
       "0      21\n",
       "1      47\n",
       "2      27\n",
       "3      75\n",
       "4      30"
      ]
     },
     "execution_count": 18,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "label.head()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 20,
   "metadata": {},
   "outputs": [],
   "source": [
    "X = features.values"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 21,
   "metadata": {},
   "outputs": [],
   "source": [
    "Y = label.values"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## 第四步：建立模型\n",
    "### 拆分数据，四分之三的数据作为训练集，四分之一的数据作为测试集"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 22,
   "metadata": {},
   "outputs": [],
   "source": [
    "from sklearn.model_selection import train_test_split\n",
    "X_train, X_test, Y_train, Y_test = train_test_split( X, Y, test_size = 1/4, random_state = 0) "
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### 用训练集的数据进行训练"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 29,
   "metadata": {},
   "outputs": [],
   "source": [
    "from sklearn.linear_model import LinearRegression\n",
    "regressor = LinearRegression()\n",
    "regressor = regressor.fit(X_train, Y_train)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### 对测试集进行预测"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 24,
   "metadata": {},
   "outputs": [],
   "source": [
    "Y_pred = regressor.predict(X_test)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## 可视化"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 30,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAXQAAAD8CAYAAABn919SAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADl0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uIDMuMC4zLCBodHRwOi8vbWF0cGxvdGxpYi5vcmcvnQurowAAGh5JREFUeJzt3XuQXGWZx/Hvk4uQBKhEEiAkTgaQ8oYg1oggFiIIKloBV6xCB0RFoyvFBqXEaCxZdIMGFBWpokwluNliQNkkXEUBMWGlkOxOQpBLwEDI5AoZIAHCBENmnv3jPU13T3cy3dOn+5w+/ftUpXreQ0/3Qy6/efo973mPuTsiItL8RiRdgIiIxEOBLiKSEQp0EZGMUKCLiGSEAl1EJCMU6CIiGaFAFxHJCAW6iEhGKNBFRDJiVCPfbOLEid7e3t7ItxQRaXorVqx4wd0nDfW8hgZ6e3s73d3djXxLEZGmZ2Y9lTxPUy4iIhmhQBcRyQgFuohIRijQRUQyQoEuIpIRCnQRkWp0dUF7O4wYER67upKu6E0NXbYoItLUurpgxgzo6wv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6Crn7FndfGX39KrAamJJwTe7uO6Lh6OhX4j+hzWwq8ClgftK1pJ2ZHQCcBCwAcPddaQnzyKnAM0mHeYFRwBgzGwWMBTYnXM+7gIfcvc/ddwP3A59JqphUBnramVk7cCywPNlK3pzaWAVsBe5198RrAn4JXAoMJF3IIA7cY2YrzGxG0sVEDgd6gd9GU1TzzWxc0kUVOAe4KekiANx9E/AzYD2wBXjZ3e9JtioeA04yswPNbCxwBvC2pIpRoFfJzPYDFgMXu/srSdfj7v3u/j5gKnBc9BEwMWb2aWCru69Iso49ONHd3w98ErgwmtpL2ijg/cB17n4s8BowK9mSgmj6Zzrw30nXAmBmE4AzgcOAQ4FxZnZukjW5+2pgLnAvYbrlEWB3UvUo0KsQzVMvBrrcfUnS9RSKPqYvAz6RcCknAtOj+erfAaeY2Q3JlhS4++bocStwC2HeM2kbgY0Fn6wWEQI+DT4JrHT355MuJPIx4Fl373X3N4AlwIcSrgl3X+Du73f3kwhTxYnMn4MCvWLRCcgFwGp3vzrpegDMbJKZjY++HkP4C/9kkjW5+/fcfaq7txM+rv/F3RPtogDMbFx0MptoSuN0wsflRLn7c8AGM3tHdOhUILET7YN8npRMt0TWA8eb2djo3+OphHNZiTKzg6LHNuBfSPD3bFRSb7w3ZnYTcDIw0cw2Ape5+4Jkq+JE4Dzg0WjOGuD77n5XgjVNBhZGKxFGADe7e2qWCabMwcAtIQcYBdzo7n9KtqQ3XQR0RVMca4EvJ1wP0XzwacDXk64lx92Xm9kiYCVhWuNhUnB1JrDYzA4E3gAudPdtSRWSymWLIiJSPU25iIhkhAJdRCQjFOgiIhmhQBcRyQgFuohIRijQRUQyQoEuIpIRCnQRkYz4f3qLpelOjmnAAAAAAElFTkSuQmCC\n",
      "text/plain": [
       "<Figure size 432x288 with 1 Axes>"
      ]
     },
     "metadata": {
      "needs_background": "light"
     },
     "output_type": "display_data"
    }
   ],
   "source": [
    "# 散点图：红色点表示训练集的点\n",
    "plt.scatter(X_train , Y_train, color = 'red')\n",
    "# 线图：蓝色线表示由训练集训练出的线性回归模型\n",
    "plt.plot(X_train , regressor.predict(X_train), color ='blue')\n",
    "plt.show()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 31,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAXQAAAD8CAYAAABn919SAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADl0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uIDMuMC4zLCBodHRwOi8vbWF0cGxvdGxpYi5vcmcvnQurowAAGo5JREFUeJzt3XuUldV9//H3V64iIsrNCYhDlGg0Cpqp0Wi0hWCrSYlNbRIDkfqTTNbPpInl1xaNbSpdJUujUZOsxIiYyCKj8UpweSsEIZGwQhwQIoKIUBAFYRCQu1zm+/tjP8PhmRmYM3MuzznP+bzWmjWzt2c434PwmS/7PHs/5u6IiEj5Oy7pAkREJD8U6CIiKaFAFxFJCQW6iEhKKNBFRFJCgS4ikhIKdBGRlFCgi4ikhAJdRCQlOhfzyfr27evV1dXFfEoRkbK3aNGiLe7er63HFTXQq6urqa+vL+ZTioiUPTNbl83jtOQiIpISCnQRkZRQoIuIpIQCXUQkJRToIiIpoUAXEUkJBbqISEoo0EVECsQdamvhV78qzvMp0EVECmD+fDjuOHjwQfja14rznAp0EZE8OnQIzjsPPvOZMB46FPbvL85zK9BFRPLk+eehc2dYtiyM586FN9+ELl2K8/xFPctFRCSNPvwQTjsNGhrC+LLL4He/C0suxaQOXUQkB3V10L17Jszr6+Hll4sf5qAOXUSkQ3buhF69MuNrr4XHHwez5GpShy4i0k4/+Uk8zN94A554ItkwB3XoIiJZ27IF+h1xm4mbboKf/jS5eppThy4ikoXbb4+H+fr1pRXmoEAXETmm9evDUsqkSWF8++1hB+igQYmW1SotuYiIHMVNN8H992fGDQ3Qt29y9bRFHbqISDMrV4auvCnMf/KT0JWXcpiDOnQRkcPcw+WHTz+dmdu5E3r2TK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XH09U5gBTAw2ao6xoNd0bBL9FG2P7nNbBDwOWBq0rVInJn1Ai4HHgJw9/3lHuaRkcDqcgpzUKC3ysyqgQuAhclW0nHREsUSYDMw293L9rUA9wH/BjQmXUieODDLzBaZWW3SxeToo0AD8MtoSWyqmZ2QdFF58BXg0aSLaC8FejNm1hN4CrjZ3XckXU9Hufshdx8ODAIuMrNPJF1TR5jZ54HN7r4o6Vry6FJ3vxC4CvimmV2edEE56AxcCNzv7hcAu4Fbki0pN9Gy0WjgiaRraS8F+hGi9eangDp3fzrpevIh+ufvPOBvEi6loy4FRkfrzr8GRpjZr5ItKTfuviH6vBmYAVyUbEU5eQd454h/AT5JCPhydhWw2N03JV1IeynQI9EbiQ8BK9z9nqTryYWZ9TOz3tHXxwOfBd5ItqqOcfdb3X2Qu1cT/hn8kruPTbisDjOzE6I33YmWJq4EliVbVce5+3vAejM7K5oaCZTdhQTNXEcZLrdA+OeSBJcCXwNei9aeAb7r7s8nWFNHVQHTonfqjwMed/eyv9wvJQYAM0L/QGfgEXd/MdmScvZPQF20VLEGuCHhejrMzHoAo4BvJF1LR+iyRRGRlNCSi4hISijQRURSQoEuIpISCnQRkZRQoIuIpIQCXUQkJRToIiIpoUAXEUmJ/w/xFop2fZ0QEAAAAABJRU5ErkJggg==\n",
      "text/plain": [
       "<Figure size 432x288 with 1 Axes>"
      ]
     },
     "metadata": {
      "needs_background": "light"
     },
     "output_type": "display_data"
    }
   ],
   "source": [
    "# 散点图：红色点表示测试集的点\n",
    "plt.scatter(X_test , Y_test, color = 'red')\n",
    "# 线图：蓝色线表示对测试集进行预测的结果\n",
    "plt.plot(X_test , regressor.predict(X_test), color ='blue')\n",
    "plt.show()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# 粉丝答疑交流QQ群：953712961\n",
    "\n",
    "\n",
    "# 微信赞赏码\n",
    "\n",
    "![子豪兄的赞赏码](https://upload-images.jianshu.io/upload_images/13714448-bec288cb077c7f08.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.7.2"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
